/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

import beans.User;
import java.sql.ResultSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import jdbc.MyJdbc;


public class LoginService {
    User user;

    public LoginService() {
    }
    
    public boolean check(String id,String psw) {
        try {
            String sql="select * from Student where ID=?";
            MyJdbc jdbc=new MyJdbc();
            jdbc.getConnection();
            ResultSet res=jdbc.query(sql, id);
            //System.out.println(id);
            if (res.next()){
                user = new User();
                user.setPasswords(res.getString(2));
                jdbc.close();
                if(user.getPasswords().equals(psw))
                    return true;
            }
        } catch (Exception ex) {
            Logger.getLogger(LoginService.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
       
    }
}
